package com.old.people.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.old.people.entities.Account;
import com.old.people.entities.OldPeople;
import com.old.people.entities.Servicer;
import com.old.people.service.LogginService;

@RestController
public class LogginController {
	@Autowired
	private LogginService logginService;

	@RequestMapping("/oldpeopleservice/userloggin")
	public boolean userLoggin(@RequestParam("oldpeople_id") String oldpeople_id,@RequestParam("oldpeople_name") String oldpeople_name,@RequestParam("oldpeople_sex") String oldpeople_sex,
			@RequestParam("oldpeople_idcard") String oldpeople_idcard,@RequestParam("oldpeople_address") String oldpeople_address,
			@RequestParam("oldpeople_tel") String oldpeople_tel, @RequestParam("oldpeople_description") String oldpeople_description, 
			@RequestParam("oldpeople_familytel") String oldpeople_familytel,@RequestParam("account_id") String account_id,
			@RequestParam("account_password") String account_password,
			@RequestParam("holder_id") String holder_id,
			@RequestParam("account_type") String account_type) {// 用户注册
		OldPeople oldPeople=new OldPeople();
		oldPeople.setOldpeople_id(oldpeople_id);
		oldPeople.setOldpeople_address(oldpeople_address);
		oldPeople.setOldpeople_description(oldpeople_description);
		oldPeople.setOldpeople_idcard(oldpeople_idcard);
		oldPeople.setOldpeople_name(oldpeople_name);
		oldPeople.setOldpeople_sex(oldpeople_sex);
		oldPeople.setOldpeople_tel(oldpeople_tel);
		oldPeople.setOldpeople_familytel(oldpeople_familytel);
		Account account=new Account();
		account.setAccount_id(account_id);
		account.setAccount_password(account_password);
		account.setHolder_id(holder_id);
		account.setAccount_type(account_type);
		return logginService.userLoggin(oldPeople, account);
	}

	@RequestMapping("/oldpeopleservice/servicerloggin")
	public boolean servicerLoggin(@RequestParam("servicer_id") String servicer_id,
			@RequestParam("servicer_name") String servicer_name, @RequestParam("servicer_sex") String servicer_sex,
			@RequestParam("servicer_tel") String servicer_tel, @RequestParam("servicer_idcard") String servicer_idcard,
			@RequestParam("service_id") String service_id, @RequestParam("account_id") String account_id,
			@RequestParam("account_password") String account_password, @RequestParam("holder_id") String holder_id,
			@RequestParam("account_type") String account_type) {// 服务者注册
		Servicer servicer=new Servicer();
		servicer.setService_id(service_id);
		servicer.setServicer_id(servicer_id);
		servicer.setServicer_idcard(servicer_idcard);
		servicer.setServicer_name(servicer_name);
		servicer.setServicer_sex(servicer_sex);
		servicer.setServicer_tel(servicer_tel);
		Account account=new Account();
		account.setAccount_id(account_id);
		account.setAccount_password(account_password);
		account.setHolder_id(holder_id);
		account.setAccount_type(account_type);
		return logginService.servicerLoggin(servicer, account);
	}

	@RequestMapping("/oldpeopleservice/managerloggin")
	public boolean managerLoggin(@RequestParam("account_id") String account_id,
			@RequestParam("account_password") String account_password, @RequestParam("holder_id") String holder_id,
			@RequestParam("account_type") String account_type) {// 管理员注册
		Account account=new Account();
		account.setAccount_id(account_id);
		account.setAccount_password(account_password);
		account.setHolder_id(holder_id);
		account.setAccount_type(account_type);
		return logginService.managerLoggin(account);
	}
}
